/*
 * Log.h
 *      Author: DePhille
 */

#ifndef LOG_H_
#define LOG_H_

#include "Log_Mini.h"


// Log object:
typedef struct {
	gchar*			protocol;	// The protocol name over which this conversation was held.
	gchar*			account;	// The account name of the conversation.
	gchar*			recipient;	// The recipient name of the conversation.
	time_t			startTime;	// The local UNIX timestamp of when the conversation started.
	unsigned int	revision;	// Version of the logFile (used to compare with server)
	gchar*			fileName;	// The filename to the log relative to the logfolder root.
	time_t			lastChange;	// Local UNIX timestamp of the last change (gathered and compared with FileSystem LastChanged)
} PC_Log;


// Methods:
static PC_Log*	PC_Log_New();
static void		PC_Log_Free(PC_Log* log);
static void		PC_Log_SetRevision(PC_Log* log, unsigned int revision);
static void		PC_Log_Write(const PC_Log* log, const gchar* contents);
static gchar*	PC_Log_Read(const PC_Log* log);
static GList*	PC_Log_FromDir(const gchar* path, const gchar* protocol, const gchar* account, const gchar* recipient);
static void		PC_Log_LoadLastChange(PC_Log* log);
static void		PC_Log_LoadStartTime(PC_Log* log);
static void		PC_Log_LoadFileName(PC_Log* log);
static PC_Log*	PC_Log_FromXML(xmlnode* xmlLogNode);
static PC_Log*	PC_Log_FromMiniLog(const PC_MiniLog* miniLog);
static void		PC_Log_LoadRecipient(PC_Log* log);
static gchar*	PC_Log_GetSQLID(const PC_Log* log);


#endif /* LOG_H_ */
